package com.microinvest.excepitionhandler;
import com.microinvest.util.Result;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

// 全局异常处理器
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result exceptionHandler(Exception e){
        e.printStackTrace();
        return Result.error(StringUtils.hasLength(e.getLocalizedMessage())?e.getMessage():"操作失败");
    }

}




